Ext.ns('WH.${entityName?lower_case}');


/**
 * ${comment!''}
 * @namespace WH.${entityName?lower_case}
 * @class WH.${entityName?lower_case}.MainPanel
 * @extends WH.util.CrudPanel
 */
WH.${entityName?lower_case}.MainPanel = Ext.extend(WH.util.CrudPanel, {
	module : '${entityName?lower_case}',
	layout : 'border',
	iconCls : 'icon-people16',
	initComponent : function() {
		
		WH.${entityName?lower_case}.MainPanel.superclass.initComponent.call(this);
		
		var me = this;
		me.formWindow = WH.${entityName?lower_case}.FormWindow;
		
	},
	initDomain:function(){
		this.domain = WH.domain.${entityName?cap_first};
		this.formWindow = WH.${entityName?lower_case}.FormWindow;
	},
	/**
	 * 创建动作列表
	 * @method
	 */
	createGrid : function() {
		// create the Grid
		var sm = new Ext.grid.CheckboxSelectionModel();
		var gridCfg = {
	            sm: sm,
	            cm: new Ext.grid.ColumnModel({
	                defaults: {
	                    sortable: true,
	                    width: 100,
	                    align: 'center'
	                },
	                columns: [sm,{header : '编号',dataIndex: 'userNo'},
                 {header : '卡号',dataIndex: 'cardNo'},
                 {header : '名称',dataIndex: 'name'},
                 {header : '电话',dataIndex: 'telephone'},
                 {header : '电子邮件',dataIndex: 'email',width: 120},
                 {header : '是否有效',dataIndex: 'isValid',renderer:function(v){
                     if (v == 'Y') {
			            return '<span style="color:green;">' + v + '</span>';
			         } else if (v == 'N') {
			            return '<span style="color:red;">' + v + '</span>';
			         }
			         return v;

                 }},
                 {header : '角色',dataIndex: 'role',width:300}
        ]
	            }),
	            // config options for stateful behavior
	            stateful: true,
	            stateId: '${entityName?lower_case}grid'
	        };
		return this.configGrid(gridCfg);
	}
});

Ext.reg('${entityName?lower_case}panel', WH.${entityName?lower_case}.MainPanel);

/**
 * @namespace WH.${entityName?lower_case}
 * @class WH.${entityName?lower_case}.FormWindow
 * @extends Ext.Window add and edit ${entityName?lower_case} window
 */
WH.${entityName?lower_case}.FormWindow = Ext.extend(WH.util.FormWindow, {
	addForm : function() {
		var me = this;
        /**
         * ${entityName?lower_case} form
         */
        me.form = me.createForm();
        me.add(me.form);
	},
	/**
	 * create ${entityName?lower_case} formpanel
	 * @method
	 */
	configForm: function(){
        return {
            items: [{
                fieldLabel: '编号',
                name: 'userNo',
                maxLength: 6
            }, {
                fieldLabel: '姓名',
                name: 'name',
                maxLength: 32
            }, {
                fieldLabel: '电子邮件',
                vtype: 'email',
                allowBlank: true,
                name: 'email'
            }, {
                fieldLabel: '电话',
                xtype: 'numberfield',
                maxLength: 11,
                allowBlank: true,
                name: 'telephone'
            }, {
                xtype: 'checkbox',
                anchor: '95%',
                checked: true,
                inputValue: 'Y',
                name: 'isValid',
                fieldLabel: '是否有效'
            }]
        };
    }
});
